package com.platform.toutiao.error;

public class TouTiaoErrorException extends Exception {
	private static final long serialVersionUID = -6357149550353160810L;

	public TouTiaoErrorException(Throwable cause) {
		super(cause);
		error = new TouTiaoError();
		error.setErrcode(999999);
		error.setErrmsg("系统异常");
	}
	private TouTiaoError error;

	public TouTiaoErrorException(TouTiaoError error) {
		super(error.toString());
		this.error = error;
	}

	public TouTiaoErrorException(TouTiaoError error, Throwable cause) {
		super(error.toString(), cause);
		this.error = error;
	}

	public TouTiaoError getError() {
		return this.error;
	}
	
	public static TouTiaoErrorException error(String errorJsonStr) {
		TouTiaoError error = TouTiaoError.fromJson(errorJsonStr);
		TouTiaoErrorException ttExption = new TouTiaoErrorException(error);
		return ttExption;
	}

}
